﻿using System;
using System.Collections.Generic;
#if USELINQ
using System.Linq;
#endif
using ICSharpCode.NRefactory.Ast;

namespace NTrace
{
    public static class TemplateDefinitionExtensions
    {
        public static List<TypeReference> CreateReferenceList(
#if USELINQ
        this
#endif
        List<TemplateDefinition> templateDefinitions)
        {
            List<TypeReference> output = new List<TypeReference>();

            System.Diagnostics.Debug.Assert(templateDefinitions != null);
            if (templateDefinitions == null) throw new ArgumentNullException("templateDefinitions");

            foreach (TemplateDefinition currentDefinition in templateDefinitions)
            {
                output.Add(TemplateDefinitionExtensions.CreateReference(currentDefinition));
            }

            return output;
        }

        public static TypeReference CreateReference(
#if USELINQ
        this
#endif
        TemplateDefinition templateDefinition)
        {
            TypeReference output;

            System.Diagnostics.Debug.Assert(templateDefinition != null);
            if (templateDefinition == null) throw new ArgumentNullException("templateDefinition");

            output = new TypeReference(templateDefinition.Name);

            return output;
        }
    }
}
